package com.bjsxt.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogInterceptor
{
//	@Pointcut("execution(public * com.bjsxt.service..*.add(..))")
	@Pointcut("execution(public * com.bjsxt.dao..*.add(..))")
	public void myMethod()
	{
	};

	@Before("myMethod()")
	public void before()
	{
		System.out.println("method start");
	}

	@After("myMethod()")
	public void after()
	{
		System.out.println("method returning");
	}

	@AfterThrowing("myMethod()")
	public void throwing()
	{
		System.out.println("throwing");
	}

	@After("myMethod()")
	public void finallyy()
	{
		System.out.println("@After...finally");
	}
	
	@Around("myMethod()")
	public void around(ProceedingJoinPoint pjp) throws Throwable{
		System.out.println("before around");
		Object obj = pjp.proceed();
		System.out.println("after around");
	}
	/*
	 * @Before("execution(public * com.bjsxt.dao..*.*(..))") public void
	 * before() { System.out.println("method start"); }
	 * 
	 * 
	 * @After("execution(public * com.bjsxt.dao..*.*(..))") public void after()
	 * { System.out.println("method returning"); }
	 */
}
